//
//  RGChatViewController.m
//  RedGrass
//
//  Created by wukong on 2019/1/28.
//  Copyright © 2019年 hongcaosp. All rights reserved.
//

#import "RGChatViewController.h"

@interface RGChatViewController ()<UIWebViewDelegate>

@property (strong, nonatomic) UIWebView *webView;

@end

@implementation RGChatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.customContentView.backgroundColor = [UIColor blackColor];
    [self showBackButton];
    self.customNavBar.title = _nickName;
    [self.customContentView addSubview:self.webView];
    [_webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsZero);
    }];
    
    //http://shortvideo.udreamtech.com/shortvideo/im/index?user_id=1&to_user_id=2
    NSString *tempUrl = [NSString stringWithFormat:@"%@?user_id=%ld&to_user_id=%ld",URL_chat,_userId,_toUserId];
    NSURL *url = [NSURL URLWithString:tempUrl];
    NSURLRequest *request =[NSURLRequest requestWithURL:url];
    [_webView loadRequest:request];
}


#pragma mark - getter

-(UIWebView *) webView{
    
    if(!_webView){
        _webView = [[UIWebView alloc]init];
        _webView.delegate = self;
        _webView.backgroundColor = [UIColor blackColor];
        _webView.scrollView.backgroundColor = [UIColor blackColor];
    }
    return _webView;
}

#pragma mark - webView deletegate
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
